﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//Please add references
using System.Collections.Generic;

namespace DAL
{
	/// <summary>
	/// 数据访问类:pe_llksjg
	/// </summary>
	public partial class pe_llksjg
	{
		public pe_llksjg()
		{}
		#region  BasicMethod
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(long id,string ksys,string kstm,int is_new,string paperBh,int ExamBh,string GWHGZSBH,string ExamAddr,string csn,DateTime addDateTime,string ksls,string gh,string xm,string sbbh,string ksmf,string ksjg,string kssj,string jssj)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from pe_llksjg");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.BigInt)
			};
			parameters[0].Value = id;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public long Add(Model.pe_llksjg model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into pe_llksjg(");
			strSql.Append("ksls,gh,xm,sbbh,ksmf,ksjg,kssj,jssj,ksys,kstm,is_new,paperBh,ExamBh,GWHGZSBH,ExamAddr,csn,addDateTime,pxkssj,pxjssj)");
			strSql.Append(" values (");
            strSql.Append("@ksls,@gh,@xm,@sbbh,@ksmf,@ksjg,@kssj,@jssj,@ksys,@kstm,@is_new,@paperBh,@ExamBh,@GWHGZSBH,@ExamAddr,@csn,@addDateTime,@pxkssj,@pxjssj)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@ksls", SqlDbType.NVarChar,50),
					new SqlParameter("@gh", SqlDbType.VarChar,50),
					new SqlParameter("@xm", SqlDbType.VarChar,50),
					new SqlParameter("@sbbh", SqlDbType.VarChar,50),
					new SqlParameter("@ksmf", SqlDbType.VarChar,50),
					new SqlParameter("@ksjg", SqlDbType.VarChar,50),
					new SqlParameter("@kssj", SqlDbType.VarChar,30),
					new SqlParameter("@jssj", SqlDbType.VarChar,30),
					new SqlParameter("@ksys", SqlDbType.VarChar,30),
					new SqlParameter("@kstm", SqlDbType.VarChar,200),
					new SqlParameter("@is_new", SqlDbType.TinyInt,1),
					new SqlParameter("@paperBh", SqlDbType.VarChar,50),
					new SqlParameter("@ExamBh", SqlDbType.Int,4),
					new SqlParameter("@GWHGZSBH", SqlDbType.NVarChar,20),
					new SqlParameter("@ExamAddr", SqlDbType.NVarChar,50),
					new SqlParameter("@csn", SqlDbType.VarChar,50),
					new SqlParameter("@addDateTime", SqlDbType.DateTime),
					new SqlParameter("@pxkssj", SqlDbType.NVarChar,20),
					new SqlParameter("@pxjssj", SqlDbType.NVarChar,20)};
			parameters[0].Value = model.ksls;
			parameters[1].Value = model.gh;
			parameters[2].Value = model.xm;
			parameters[3].Value = model.sbbh;
			parameters[4].Value = model.ksmf;
			parameters[5].Value = model.ksjg;
			parameters[6].Value = model.kssj;
			parameters[7].Value = model.jssj;
			parameters[8].Value = model.ksys;
			parameters[9].Value = model.kstm;
			parameters[10].Value = model.is_new;
			parameters[11].Value = model.paperBh;
			parameters[12].Value = model.ExamBh;
			parameters[13].Value = model.GWHGZSBH;
			parameters[14].Value = model.ExamAddr;
            parameters[15].Value = model.csn;
            parameters[16].Value = model.addDateTime;
            parameters[17].Value = model.pxkssj;
            parameters[18].Value = model.pxjssj;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt64(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Model.pe_llksjg model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update pe_llksjg set ");
			strSql.Append("ksls=@ksls,");
			strSql.Append("gh=@gh,");
			strSql.Append("xm=@xm,");
			strSql.Append("sbbh=@sbbh,");
			strSql.Append("ksmf=@ksmf,");
			strSql.Append("ksjg=@ksjg,");
			strSql.Append("kssj=@kssj,");
			strSql.Append("jssj=@jssj,");
			strSql.Append("ksys=@ksys,");
			strSql.Append("kstm=@kstm,");
			strSql.Append("is_new=@is_new,");
			strSql.Append("paperBh=@paperBh,");
			strSql.Append("ExamBh=@ExamBh,");
			strSql.Append("GWHGZSBH=@GWHGZSBH,");
            strSql.Append("ExamAddr=@ExamAddr,");
            strSql.Append("pxkssj=@pxkssj,");
            strSql.Append("pxjssj=@pxjssj,");
			strSql.Append("csn=@csn,");
			strSql.Append("addDateTime=@addDateTime");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@ksls", SqlDbType.NVarChar,50),
					new SqlParameter("@gh", SqlDbType.VarChar,50),
					new SqlParameter("@xm", SqlDbType.VarChar,50),
					new SqlParameter("@sbbh", SqlDbType.VarChar,50),
					new SqlParameter("@ksmf", SqlDbType.VarChar,50),
					new SqlParameter("@ksjg", SqlDbType.VarChar,50),
					new SqlParameter("@kssj", SqlDbType.VarChar,30),
					new SqlParameter("@jssj", SqlDbType.VarChar,30),
					new SqlParameter("@ksys", SqlDbType.VarChar,30),
					new SqlParameter("@kstm", SqlDbType.VarChar,200),
					new SqlParameter("@is_new", SqlDbType.TinyInt,1),
					new SqlParameter("@paperBh", SqlDbType.VarChar,50),
					new SqlParameter("@ExamBh", SqlDbType.Int,4),
					new SqlParameter("@GWHGZSBH", SqlDbType.NVarChar,20),
					new SqlParameter("@ExamAddr", SqlDbType.NVarChar,50),
					new SqlParameter("@csn", SqlDbType.VarChar,50),
					new SqlParameter("@addDateTime", SqlDbType.DateTime),
					new SqlParameter("@id", SqlDbType.BigInt,8),
					new SqlParameter("@pxkssj", SqlDbType.NVarChar,20),
					new SqlParameter("@pxjssj", SqlDbType.NVarChar,20)};
			parameters[0].Value = model.ksls;
			parameters[1].Value = model.gh;
			parameters[2].Value = model.xm;
			parameters[3].Value = model.sbbh;
			parameters[4].Value = model.ksmf;
			parameters[5].Value = model.ksjg;
			parameters[6].Value = model.kssj;
			parameters[7].Value = model.jssj;
			parameters[8].Value = model.ksys;
			parameters[9].Value = model.kstm;
			parameters[10].Value = model.is_new;
			parameters[11].Value = model.paperBh;
			parameters[12].Value = model.ExamBh;
			parameters[13].Value = model.GWHGZSBH;
			parameters[14].Value = model.ExamAddr;
			parameters[15].Value = model.csn;
            parameters[16].Value = model.addDateTime;
            parameters[17].Value = model.id;
            parameters[18].Value = model.pxkssj;
            parameters[19].Value = model.pxjssj;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(long id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from pe_llksjg ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.BigInt)
			};
			parameters[0].Value = id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string idlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from pe_llksjg ");
			strSql.Append(" where id in ("+idlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.pe_llksjg GetModel(long id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 id,ksls,gh,xm,sbbh,ksmf,ksjg,kssj,jssj,ksys,kstm,is_new,paperBh,ExamBh,GWHGZSBH,ExamAddr,csn,addDateTime,pxkssj,pxjssj from pe_llksjg ");
			strSql.Append(" where id=@id");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.BigInt)
			};
			parameters[0].Value = id;

			Model.pe_llksjg model=new Model.pe_llksjg();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}

        /// <summary>
        /// 根据条件得到一个对象实体
        /// </summary>
        public Model.pe_llksjg GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select id,ksls,gh,xm,sbbh,ksmf,ksjg,kssj,jssj,ksys,kstm,is_new,paperBh,ExamBh,GWHGZSBH,ExamAddr,csn,addDateTime,pxkssj,pxjssj ");
            strSql.Append(" FROM pe_llksjg ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            DataSet ds= DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.pe_llksjg DataRowToModel(DataRow row)
		{
			Model.pe_llksjg model=new Model.pe_llksjg();
			if (row != null)
			{
				if(row["id"]!=null && row["id"].ToString()!="")
				{
					model.id=long.Parse(row["id"].ToString());
				}
				if(row["ksls"]!=null)
				{
					model.ksls=row["ksls"].ToString();
				}
				if(row["gh"]!=null)
				{
					model.gh=row["gh"].ToString();
				}
				if(row["xm"]!=null)
				{
					model.xm=row["xm"].ToString();
				}
				if(row["sbbh"]!=null)
				{
					model.sbbh=row["sbbh"].ToString();
				}
				if(row["ksmf"]!=null)
				{
					model.ksmf=row["ksmf"].ToString();
				}
				if(row["ksjg"]!=null)
				{
					model.ksjg=row["ksjg"].ToString();
				}
				if(row["kssj"]!=null)
				{
					model.kssj=row["kssj"].ToString();
				}
				if(row["jssj"]!=null)
				{
					model.jssj=row["jssj"].ToString();
				}
				if(row["ksys"]!=null)
				{
					model.ksys=row["ksys"].ToString();
				}
				if(row["kstm"]!=null)
				{
					model.kstm=row["kstm"].ToString();
				}
				if(row["is_new"]!=null && row["is_new"].ToString()!="")
				{
					model.is_new=int.Parse(row["is_new"].ToString());
				}
				if(row["paperBh"]!=null)
				{
					model.paperBh=row["paperBh"].ToString();
				}
				if(row["ExamBh"]!=null && row["ExamBh"].ToString()!="")
				{
					model.ExamBh=int.Parse(row["ExamBh"].ToString());
				}
				if(row["GWHGZSBH"]!=null)
				{
					model.GWHGZSBH=row["GWHGZSBH"].ToString();
				}
				if(row["ExamAddr"]!=null)
				{
					model.ExamAddr=row["ExamAddr"].ToString();
				}
				if(row["csn"]!=null)
				{
					model.csn=row["csn"].ToString();
				}
				if(row["addDateTime"]!=null && row["addDateTime"].ToString()!="")
				{
					model.addDateTime=DateTime.Parse(row["addDateTime"].ToString());
                }
                if (row["pxkssj"] != null)
                {
                    model.pxkssj = row["pxkssj"].ToString();
                }
                if (row["pxjssj"] != null)
                {
                    model.pxjssj = row["pxjssj"].ToString();
                }
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select id,ksls,gh,xm,sbbh,ksmf,ksjg,kssj,jssj,ksys,kstm,is_new,paperBh,ExamBh,GWHGZSBH,ExamAddr,csn,addDateTime,pxkssj,pxjssj ");
			strSql.Append(" FROM pe_llksjg ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" id,ksls,gh,xm,sbbh,ksmf,ksjg,kssj,jssj,ksys,kstm,is_new,paperBh,ExamBh,GWHGZSBH,ExamAddr,csn,addDateTime,pxkssj,pxjssj ");
			strSql.Append(" FROM pe_llksjg ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM pe_llksjg ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.id desc");
			}
			strSql.Append(")AS Row, T.*  from pe_llksjg T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "pe_llksjg";
			parameters[1].Value = "id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

        /// <summary>
        /// 增加主表和子表多条行记录
        /// </summary>
        public long AddToTableList(List< Model.pe_llksjg> modelksjg,List<Model.pe_llksjginfo> modelksjginfo)
        {
            List<DBUtility.CommandInfo> commandinfoList = new List<CommandInfo>();
            DBUtility.CommandInfo commandinfo = new CommandInfo();
            foreach(Model.pe_llksjg model in modelksjg)
            {

                string sql = " select ksjg from pe_llksjg where gh='"+model.gh+"' and paperBh='"+model.paperBh+"' ";

                StringBuilder strSql = new StringBuilder();
                if (!DbHelperSQL.Exists(sql))
                {
                    //如果对应成绩不存在，添加成绩
                    strSql.Append("insert into pe_llksjg(");
                    strSql.Append("ksls,gh,xm,sbbh,ksmf,ksjg,kssj,jssj,ksys,kstm,is_new,paperBh,ExamBh,GWHGZSBH,ExamAddr,csn,addDateTime,pxkssj,pxjssj)");
                    strSql.Append(" values (");
                    strSql.Append("@ksls,@gh,@xm,@sbbh,@ksmf,@ksjg,@kssj,@jssj,@ksys,@kstm,@is_new,@paperBh,@ExamBh,@GWHGZSBH,@ExamAddr,@csn,@addDateTime,@pxkssj,@pxjssj)");
                    strSql.Append(";select @@IDENTITY");
                    SqlParameter[] parameters = {
					new SqlParameter("@ksls", SqlDbType.NVarChar,50),
					new SqlParameter("@gh", SqlDbType.VarChar,50),
					new SqlParameter("@xm", SqlDbType.VarChar,50),
					new SqlParameter("@sbbh", SqlDbType.VarChar,50),
					new SqlParameter("@ksmf", SqlDbType.VarChar,50),
					new SqlParameter("@ksjg", SqlDbType.VarChar,50),
					new SqlParameter("@kssj", SqlDbType.VarChar,30),
					new SqlParameter("@jssj", SqlDbType.VarChar,30),
					new SqlParameter("@ksys", SqlDbType.VarChar,30),
					new SqlParameter("@kstm", SqlDbType.VarChar,200),
					new SqlParameter("@is_new", SqlDbType.TinyInt,1),
					new SqlParameter("@paperBh", SqlDbType.VarChar,50),
					new SqlParameter("@ExamBh", SqlDbType.Int,4),
					new SqlParameter("@GWHGZSBH", SqlDbType.NVarChar,20),
					new SqlParameter("@ExamAddr", SqlDbType.NVarChar,50),
					new SqlParameter("@csn", SqlDbType.VarChar,50),
					new SqlParameter("@addDateTime", SqlDbType.DateTime),
					new SqlParameter("@pxkssj", SqlDbType.NVarChar,20),
					new SqlParameter("@pxjssj", SqlDbType.NVarChar,20)};
                    parameters[0].Value = model.ksls;
                    parameters[1].Value = model.gh;
                    parameters[2].Value = model.xm;
                    parameters[3].Value = model.sbbh;
                    parameters[4].Value = model.ksmf;
                    parameters[5].Value = model.ksjg;
                    parameters[6].Value = model.kssj;
                    parameters[7].Value = model.jssj;
                    parameters[8].Value = model.ksys;
                    parameters[9].Value = model.kstm;
                    parameters[10].Value = model.is_new;
                    parameters[11].Value = model.paperBh;
                    parameters[12].Value = model.ExamBh;
                    parameters[13].Value = model.GWHGZSBH;
                    parameters[14].Value = model.ExamAddr;
                    parameters[15].Value = model.csn;
                    parameters[16].Value = model.addDateTime;
                    parameters[17].Value = model.pxkssj;
                    parameters[18].Value = model.pxjssj;

                    commandinfo = new CommandInfo(strSql.ToString(), parameters);
                }
                else
                {
                    //如果该试卷该员工已经存在，更新成绩
                    strSql.Append("update pe_llksjg set ");
                    strSql.Append("ksls=@ksls,");
                    strSql.Append("xm=@xm,");
                    strSql.Append("sbbh=@sbbh,");
                    strSql.Append("ksmf=@ksmf,");
                    strSql.Append("ksjg=@ksjg,");
                    strSql.Append("kssj=@kssj,");
                    strSql.Append("jssj=@jssj,");
                    strSql.Append("ksys=@ksys,");
                    strSql.Append("kstm=@kstm,");
                    strSql.Append("is_new=@is_new,"); 
                    strSql.Append("ExamBh=@ExamBh,");
                    strSql.Append("GWHGZSBH=@GWHGZSBH,");
                    strSql.Append("ExamAddr=@ExamAddr,");
                    strSql.Append("csn=@csn,");
                    strSql.Append("addDateTime=@addDateTime, ");
                    strSql.Append("pxkssj=@pxkssj,");
                    strSql.Append("pxjssj=@pxjssj");
                    strSql.Append(" where gh=@gh and paperBh=@paperBh");
                    SqlParameter[] parameters = {
					new SqlParameter("@ksls", SqlDbType.NVarChar,50),
					new SqlParameter("@gh", SqlDbType.VarChar,50),
					new SqlParameter("@xm", SqlDbType.VarChar,50),
					new SqlParameter("@sbbh", SqlDbType.VarChar,50),
					new SqlParameter("@ksmf", SqlDbType.VarChar,50),
					new SqlParameter("@ksjg", SqlDbType.VarChar,50),
					new SqlParameter("@kssj", SqlDbType.VarChar,30),
					new SqlParameter("@jssj", SqlDbType.VarChar,30),
					new SqlParameter("@ksys", SqlDbType.VarChar,30),
					new SqlParameter("@kstm", SqlDbType.VarChar,200),
					new SqlParameter("@is_new", SqlDbType.TinyInt,1),
					new SqlParameter("@paperBh", SqlDbType.VarChar,50),
					new SqlParameter("@ExamBh", SqlDbType.Int,4),
					new SqlParameter("@GWHGZSBH", SqlDbType.NVarChar,20),
					new SqlParameter("@ExamAddr", SqlDbType.NVarChar,50),
					new SqlParameter("@csn", SqlDbType.VarChar,50),
					new SqlParameter("@addDateTime", SqlDbType.DateTime),
					new SqlParameter("@pxkssj", SqlDbType.NVarChar,20),
					new SqlParameter("@pxjssj", SqlDbType.NVarChar,20) };
                    parameters[0].Value = model.ksls;
                    parameters[1].Value = model.gh;
                    parameters[2].Value = model.xm;
                    parameters[3].Value = model.sbbh;
                    parameters[4].Value = model.ksmf;
                    parameters[5].Value = model.ksjg;
                    parameters[6].Value = model.kssj;
                    parameters[7].Value = model.jssj;
                    parameters[8].Value = model.ksys;
                    parameters[9].Value = model.kstm;
                    parameters[10].Value = model.is_new;
                    parameters[11].Value = model.paperBh;
                    parameters[12].Value = model.ExamBh;
                    parameters[13].Value = model.GWHGZSBH;
                    parameters[14].Value = model.ExamAddr;
                    parameters[15].Value = model.csn;
                    parameters[16].Value = model.addDateTime;
                    parameters[17].Value = model.pxkssj;
                    parameters[18].Value = model.pxjssj;

                    commandinfo = new CommandInfo(strSql.ToString(), parameters);
                }
                commandinfoList.Add(commandinfo); 
            }
            foreach (Model.pe_llksjginfo model in modelksjginfo)
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into pe_llksjginfo(");
                strSql.Append("ksls,TiX,stbh,RightAnswer,ksAnswer,fs,csn,addDateTime)");
                strSql.Append(" values (");
                strSql.Append("@ksls,@TiX,@stbh,@RightAnswer,@ksAnswer,@fs,@csn,@addDateTime)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters = {
					new SqlParameter("@ksls", SqlDbType.NVarChar,50),
					new SqlParameter("@TiX", SqlDbType.NVarChar,50),
					new SqlParameter("@stbh", SqlDbType.Int,4),
					new SqlParameter("@RightAnswer", SqlDbType.NVarChar,50),
					new SqlParameter("@ksAnswer", SqlDbType.NVarChar,50),
					new SqlParameter("@fs", SqlDbType.NVarChar,50),
					new SqlParameter("@csn", SqlDbType.VarChar,50),
					new SqlParameter("@addDateTime", SqlDbType.DateTime)};
                parameters[0].Value = model.ksls;
                parameters[1].Value = model.TiX;
                parameters[2].Value = model.stbh;
                parameters[3].Value = model.RightAnswer;
                parameters[4].Value = model.ksAnswer;
                parameters[5].Value = model.fs;
                parameters[6].Value = model.csn;
                parameters[7].Value = model.addDateTime;
                

                commandinfo = new CommandInfo(strSql.ToString(), parameters);
                commandinfoList.Add(commandinfo); 
            }
            return DbHelperSQL.ExecuteSqlTran(commandinfoList);
        }
		#endregion  ExtensionMethod
	}
}

